<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【请填写功能名称】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>箱型号名称：</p>
                                <input type="text" name="modelName"/>
                            </li>
                            <li>
                                <p>箱型号编号：</p>
                                <input type="text" name="modelCode"/>
                            </li>
                            <li>
                                <p>电池品牌：</p>
                                <input type="text" name="cellCard"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:boxmodel:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:boxmodel:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:boxmodel:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:boxmodel:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>

     <a href="#powerModal" role="button" class="btn" data-toggle="modal">查看演示案例</a>

     <!-- Modal -->
     <div  class="modal fade" id="powerModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
         <div class="modal-dialog" role="document">
             <div class="modal-content" style="width: 800px;height:600px">
                 <div class="modal-header">
                     <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                     <h4 class="modal-title" id="myModalLabel">电池箱型号性能参数</h4>
                 </div>
                 <div class="modal-body">
                     <div class="col-md-12">
                         <div class="form-group">
                             <label class="col-sm-3 control-label">外形：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="appearance" class="form-control" readonly>
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">尺寸：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="size" class="form-control" readonly>mm
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">额定容量：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="capacity" class="form-control" readonly>Ah
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">标称电压：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="voltage" class="form-control" readonly>V
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">额定质量：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="weight" class="form-control" readonly>kg
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">能量密度：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="energyDensity" class="form-control" readonly>Wh/kg
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">功率密度：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="powerDensity" class="form-control" readonly>w/kg
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">充电倍率：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="chargeRate" class="form-control" readonly>C
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">电池寿命：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="batteryLife" class="form-control" readonly>年
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">温度探针总数：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="probeCount" class="form-control" readonly>
                             </div>
                         </div>
                     </div>
                 </div>
                 <div class="modal-footer">
                     <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                 </div>
             </div>
         </div>
     </div>

     <a href="#myModal" role="button" class="btn" data-toggle="modal">查看演示案例</a>

     <!-- Modal -->
     <div  class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
         <div class="modal-dialog" role="document">
             <div class="modal-content" style="width: 700px;height:200px">
                 <div class="modal-header">
                     <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                     <h4 class="modal-title" id="myModalLabel">电池箱模块型号参数</h4>
                 </div>
                 <div class="modal-body">
                     <div class="col-md-12">
                         <div class="form-group">
                             <label class="col-sm-3 control-label">模块串并联方式：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="modelType" class="form-control" readonly>
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">模块个数：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="modelCount" class="form-control" readonly>
                             </div>
                         </div><br>
                     </div>
                 </div>
                 <div class="modal-footer">
                     <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                 </div>
             </div>
         </div>
     </div>

    <th:block th:include="include :: footer" />
    <script th:inline="javascript" type="text/javascript">
        var editFlag = [[${@permission.hasPermi('system:boxmodel:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:boxmodel:remove')}]];
        var prefix = ctx + "system/boxmodel";

        function powerdetail(id){
            $.ajax({
                url:prefix+"/powerdetail",
                type:"get",
                data:{'modelId':id},
                success:function (data){
                    console.log(data);
                    $("[name='appearance']").val(data.appearance);
                    $("[name='size']").val(data.size);
                    $("[name='capacity']").val(data.capacity);
                    $("[name='voltage']").val(data.voltage);
                    $("[name='weight']").val(data.weight);
                    $("[name='energyDensity']").val(data.energyDensity);
                    $("[name='powerDensity']").val(data.powerDensity);
                    $("[name='chargeRate']").val(data.chargeRate);
                    $("[name='batteryLife']").val(data.batteryLife);
                },
                datatype:"json"
            })
        }
        function modeldetail(id){
            $.ajax({
                url:prefix+"/modeldetail",
                type:"get",
                data:{'modelId':id},
                success:function (data){
                    console.log(data);
                    $("[name='modelType']").val(data.modelType);
                    $("[name='modelCount']").val(data.modelCount);
                },
                datatype:"json"
            })
        }

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "【请填写功能名称】",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'modelId', 
                    title : '编号',
                    visible: false
                },
                {
                    field : 'modelName', 
                    title : '箱型号名称'
                },
                {
                    field : 'modelCode', 
                    title : '箱型号编号'
                },
                {
                    field : 'specificationsCode', 
                    title : '箱规格代码'
                },
                {
                    field : 'cellCard', 
                    title : '电池品牌'
                },
                {
                    field : 'probeCount', 
                    title : '恩度探针总数'
                },
                {
                    field : 'modelType', 
                    title : '模块串并联方式'
                },
                {
                    field : 'modelCount', 
                    title : '模块个数'
                },
                {
                    field : 'companyName', 
                    title : '生产厂商名称'
                },
                {
                    title : '电池包型号性能参数',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a data-toggle="modal" data-target="#powerModal" onclick="powerdetail(\'' + row.modelId + '\')"></i>查看详细信息</a>');
                        return actions.join('');
                    }
                },
                {
                    title : '电池包型号模块参数',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a data-toggle="modal" data-target="#myModal" onclick="modeldetail(\'' + row.modelId + '\')"></i>查看详细信息</a>');
                        return actions.join('');
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.modelId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.modelId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>